package luogu;

import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int len=sc.nextInt();
        int n=sc.nextInt();
        int[] tree= new int[len+1];


        for (int i=0;i<n;i++) {
            int strat =sc.nextInt();
            int end =sc.nextInt();
            setzero(tree,strat,end);
        }

        int count =0;
        for (int i = 0; i < tree.length; i++) {
            if(tree[i]==0){
                count++;
            }
        }
        System.out.println(count);
    }

    private static void setzero(int[] tree,int strat, int end) {
        for (int i=strat;i<=end;i++){
            tree[i]=1;
        }
    }
}
